***********************************************************************
* This Stata dofile was written for Stata 7.0, by Andrew Leigh. It is to accompany the paper
* "Employment Effects of Minimum Wages: Evidence from a Quasi-Experiment", published
* in the Australian Economic Review, December 2003.
* This dofile was amended in February 2004, to correct an earlier error. The erratum is available
* from the author.
* Any questions should
* be directed to andrew_leigh@ksg02.harvard.edu (lifetime email address).
***********************************************************************

clear
set mem 20m
set matsize 800
version 7.0
set more off
cd "C:\Documents and Settings\Andrew\My publications\WA Minimum Wages\2004 reanalysis\"

**********************************************
* The following file combines data from various SuperTable extracts
* From SuperTable, I extracted monthly figures on FT employment, PT employment
* population, and labour force for each age group, state/territory, and month, from 1978-2002
* There are too many variables to present this data in Excel format.
* Note that the labour force data is not used in the regressions that follow. It is merely included in the dataset
* because the published version of the paper erroneously used employment to labour force ratios, 
* in place of employment to population ratios.
**********************************************
use minimum_wage_data_web1.dta, replace

* Replacing missing figures with zeros
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: for Z in any 15_19 20_24 25_29 30_34 35_39 40_44 45_49 50_54 55_59 60_64 65_69 70_up: replace Y_XZ=0 if Y_XZ==.
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: for Z in any 15_19 20_24 25_29 30_34 35_39 40_44 45_49 50_54 55_59 60_64 65_69 70_up: replace Y_XZm=0 if Y_XZm==.
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: for Z in any 15_19 20_24 25_29 30_34 35_39 40_44 45_49 50_54 55_59 60_64 65_69 70_up: replace Y_XZf=0 if Y_XZf==.

* Creating population totals by summing those aged 15 and over.
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt pop: gen Y_X=Y_X15_19+Y_X20_24+Y_X25_29+Y_X30_34+Y_X35_39+Y_X40_44+Y_X45_49+Y_X50_54+Y_X55_59+Y_X60_64+Y_X65_69+Y_X70_up
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt pop: gen Y_Xm=Y_X15_19m+Y_X20_24m+Y_X25_29m+Y_X30_34m+Y_X35_39m+Y_X40_44m+Y_X45_49m+Y_X50_54m+Y_X55_59m+Y_X60_64m+Y_X65_69m+Y_X70_upm
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt pop: gen Y_Xf=Y_X15_19f+Y_X20_24f+Y_X25_29f+Y_X30_34f+Y_X35_39f+Y_X40_44f+Y_X45_49f+Y_X50_54f+Y_X55_59f+Y_X60_64f+Y_X65_69f+Y_X70_upf

**********************************************
* Setting minimum wage dummies - these are 1 in the month 
* of the increase, zero otherwise
**********************************************

gen mw_94=1 if yearmonth==199408
gen mw_95=1 if yearmonth==199509
gen mw_96=1 if yearmonth==199610
gen mw_98=1 if yearmonth==199812
gen mw_00=1 if yearmonth==200003
gen mw_01=1 if yearmonth==200103
for any 94 95 96 98 00 01: recode mw_X .=0 \ la var mw_X "Month when Western Australian minimum wage was increased in 'X"
gen mw=0
replace mw=.0929 if yearmonth==199408
replace mw=.0531 if yearmonth==199509
replace mw=.0469 if yearmonth==199610
replace mw=.0349 if yearmonth==199812
replace mw=.0614 if yearmonth==200003
replace mw=.0880 if yearmonth==200103
la var mw "Percentage increase in Western Australian minimum wage"
sort yearmonth
gen n=_n
tsset n

**********************************************
* Creating full time equivalent, seasonally adjusted, 
* employment to population ratios
**********************************************

* FTE employment - total population
gen fte_wa=(ft_wa+15/40*pt_wa)/pop_wa
gen fte_ra=((ft_nsw+ft_vic+ft_q+ft_sa+ft_tas+ft_nt+ft_act)+15/40*(pt_nsw+pt_vic+pt_q+pt_sa+pt_tas+pt_nt+pt_act))/(pop_nsw+pop_vic+pop_q+pop_sa+pop_tas+pop_nt+pop_act)
la var fte_wa "FTE employment to population ratio - Western Australia"
la var fte_ra "FTE employment to population ratio - Rest of Australia"

* FTE employment - by age-sex subgroups
* Collapsing five-year age bands into 10-year age bands
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X15_24=Y_X15_19+Y_X20_24
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X15_24f=Y_X15_19f+Y_X20_24f
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X15_24m=Y_X15_19m+Y_X20_24m
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X25_34=Y_X25_29+Y_X30_34
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X25_34f=Y_X25_29f+Y_X30_34f
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X25_34m=Y_X25_29m+Y_X30_34m
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X35_44=Y_X35_39+Y_X40_44
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X35_44m=Y_X35_39m+Y_X40_44m
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X35_44f=Y_X35_39f+Y_X40_44f
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X45_54=Y_X45_49+Y_X50_54
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X45_54m=Y_X45_49m+Y_X50_54m
for X in any nsw vic q sa tas wa nt act: for Y in any ft pt lf pop: gen Y_X45_54f=Y_X45_49f+Y_X50_54f

* FTE employment - age-sex subgroups (and with PT=20 hrs)
for any 15_24 25_34 35_44 45_54 15_24m 25_34m 35_44m 45_54m 15_24f 25_34f 35_44f 45_54f m f: gen fte_waX=(ft_waX+15/40*pt_waX)/pop_waX \ gen fte_raX=((ft_nswX+ft_vicX+ft_qX+ft_saX+ft_tasX+ft_ntX+ft_actX)+15/40*(pt_nswX+pt_vicX+pt_qX+pt_saX+pt_tasX+pt_ntX+pt_actX))/(pop_nswX+pop_vicX+pop_qX+pop_saX+pop_tasX+pop_ntX+pop_actX)
gen fte_wa20h=(ft_wa+20/40*pt_wa)/pop_wa
gen fte_ra20h=((ft_nsw+ft_vic+ft_q+ft_sa+ft_tas+ft_nt+ft_act)+20/40*(pt_nsw+pt_vic+pt_q+pt_sa+pt_tas+pt_nt+pt_act))/(pop_nsw+pop_vic+pop_q+pop_sa+pop_tas+pop_nt+pop_act)

* Seasonal adjustment
gen sa_fte_wa=fte_wa*12*(l12.fte_wa+l24.fte_wa+l36.fte_wa)/(l1.fte_wa+l2.fte_wa+l3.fte_wa+l4.fte_wa+l5.fte_wa+l6.fte_wa+l7.fte_wa+l8.fte_wa+l9.fte_wa+l10.fte_wa+l11.fte_wa+l12.fte_wa+l13.fte_wa+l14.fte_wa+l15.fte_wa+l16.fte_wa+l17.fte_wa+l18.fte_wa+l19.fte_wa+l20.fte_wa+l21.fte_wa+l22.fte_wa+l23.fte_wa+l24.fte_wa+l25.fte_wa+l26.fte_wa+l27.fte_wa+l28.fte_wa+l29.fte_wa+l30.fte_wa+l31.fte_wa+l32.fte_wa+l33.fte_wa+l34.fte_wa+l35.fte_wa+l36.fte_wa) if yearmonth>=198102
gen sa_fte_ra=fte_ra*12*(l12.fte_ra+l24.fte_ra+l36.fte_ra)/(l1.fte_ra+l2.fte_ra+l3.fte_ra+l4.fte_ra+l5.fte_ra+l6.fte_ra+l7.fte_ra+l8.fte_ra+l9.fte_ra+l10.fte_ra+l11.fte_ra+l12.fte_ra+l13.fte_ra+l14.fte_ra+l15.fte_ra+l16.fte_ra+l17.fte_ra+l18.fte_ra+l19.fte_ra+l20.fte_ra+l21.fte_ra+l22.fte_ra+l23.fte_ra+l24.fte_ra+l25.fte_ra+l26.fte_ra+l27.fte_ra+l28.fte_ra+l29.fte_ra+l30.fte_ra+l31.fte_ra+l32.fte_ra+l33.fte_ra+l34.fte_ra+l35.fte_ra+l36.fte_ra) if yearmonth>=198102
la var sa_fte_wa "Seasonally adjusted FTE employment to population ratio - Western Australia"
la var sa_fte_ra "Seasonally adjusted FTE employment to population ratio - Rest of Australia"
for any 15_24 25_34 35_44 45_54 15_24m 25_34m 35_44m 45_54m 15_24f 25_34f 35_44f 45_54f m f 20h: gen sa_fte_waX=fte_waX*12*(l12.fte_waX+l24.fte_waX+l36.fte_waX)/(l1.fte_waX+l2.fte_waX+l3.fte_waX+l4.fte_waX+l5.fte_waX+l6.fte_waX+l7.fte_waX+l8.fte_waX+l9.fte_waX+l10.fte_waX+l11.fte_waX+l12.fte_waX+l13.fte_waX+l14.fte_waX+l15.fte_waX+l16.fte_waX+l17.fte_waX+l18.fte_waX+l19.fte_waX+l20.fte_waX+l21.fte_waX+l22.fte_waX+l23.fte_waX+l24.fte_waX+l25.fte_waX+l26.fte_waX+l27.fte_waX+l28.fte_waX+l29.fte_waX+l30.fte_waX+l31.fte_waX+l32.fte_waX+l33.fte_waX+l34.fte_waX+l35.fte_waX+l36.fte_waX) if yearmonth>=198102 \ gen sa_fte_raX=fte_raX*12*(l12.fte_raX+l24.fte_raX+l36.fte_raX)/(l1.fte_raX+l2.fte_raX+l3.fte_raX+l4.fte_raX+l5.fte_raX+l6.fte_raX+l7.fte_raX+l8.fte_raX+l9.fte_raX+l10.fte_raX+l11.fte_raX+l12.fte_raX+l13.fte_raX+l14.fte_raX+l15.fte_raX+l16.fte_raX+l17.fte_raX+l18.fte_raX+l19.fte_raX+l20.fte_raX+l21.fte_raX+l22.fte_raX+l23.fte_raX+l24.fte_raX+l25.fte_raX+l26.fte_raX+l27.fte_raX+l28.fte_raX+l29.fte_raX+l30.fte_raX+l31.fte_raX+l32.fte_raX+l33.fte_raX+l34.fte_raX+l35.fte_raX+l36.fte_raX) if yearmonth>=198102
la var sa_fte_wa15_24 "Seasonally adjusted FTE employment to population ratio for 15-24 yo - Western Australia"
la var sa_fte_ra15_24 "Seasonally adjusted FTE employment to population ratio for 15-24 yo - Rest of Australia"
la var sa_fte_wa25_34 "Seasonally adjusted FTE employment to population ratio for 25-34 yo - Western Australia"
la var sa_fte_ra25_34 "Seasonally adjusted FTE employment to population ratio for 25-34 yo - Rest of Australia"
la var sa_fte_wa35_44 "Seasonally adjusted FTE employment to population ratio for 35-44 yo - Western Australia"
la var sa_fte_ra35_44 "Seasonally adjusted FTE employment to population ratio for 35-44 yo - Rest of Australia"
la var sa_fte_wa45_54 "Seasonally adjusted FTE employment to population ratio for 45-54 yo - Western Australia"
la var sa_fte_ra45_54 "Seasonally adjusted FTE employment to population ratio for 45-54 yo - Rest of Australia"
la var sa_fte_wa15_24m "Seasonally adjusted FTE employment to population ratio for 15-24 yo males - Western Australia"
la var sa_fte_ra15_24m "Seasonally adjusted FTE employment to population ratio for 15-24 yo males - Rest of Australia"
la var sa_fte_wa25_34m "Seasonally adjusted FTE employment to population ratio for 25-34 yo males - Western Australia"
la var sa_fte_ra25_34m "Seasonally adjusted FTE employment to population ratio for 25-34 yo males - Rest of Australia"
la var sa_fte_wa35_44m "Seasonally adjusted FTE employment to population ratio for 35-44 yo males - Western Australia"
la var sa_fte_ra35_44m "Seasonally adjusted FTE employment to population ratio for 35-44 yo males - Rest of Australia"
la var sa_fte_wa45_54m "Seasonally adjusted FTE employment to population ratio for 45-54 yo males - Western Australia"
la var sa_fte_ra45_54m "Seasonally adjusted FTE employment to population ratio for 45-54 yo males - Rest of Australia"
la var sa_fte_wa15_24f "Seasonally adjusted FTE employment to population ratio for 15-24 yo females - Western Australia"
la var sa_fte_ra15_24f "Seasonally adjusted FTE employment to population ratio for 15-24 yo females - Rest of Australia"
la var sa_fte_wa25_34f "Seasonally adjusted FTE employment to population ratio for 25-34 yo females - Western Australia"
la var sa_fte_ra25_34f "Seasonally adjusted FTE employment to population ratio for 25-34 yo females - Rest of Australia"
la var sa_fte_wa35_44f "Seasonally adjusted FTE employment to population ratio for 35-44 yo females - Western Australia"
la var sa_fte_ra35_44f "Seasonally adjusted FTE employment to population ratio for 35-44 yo females - Rest of Australia"
la var sa_fte_wa45_54f "Seasonally adjusted FTE employment to population ratio for 45-54 yo females - Western Australia"
la var sa_fte_ra45_54f "Seasonally adjusted FTE employment to population ratio for 45-54 yo females - Rest of Australia"
la var sa_fte_wam "Seasonally adjusted FTE employment to population ratio - Males - Western Australia"
la var sa_fte_ram "Seasonally adjusted FTE employment to population ratio - Males - Rest of Australia"
la var sa_fte_waf "Seasonally adjusted FTE employment to population ratio - Females - Western Australia"
la var sa_fte_raf "Seasonally adjusted FTE employment to population ratio - Females - Rest of Australia"
la var sa_fte_wa20h "Seasonally adjusted FTE employment to population ratio - using PT 20 hrs - Western Australia"
la var sa_fte_ra20h "Seasonally adjusted FTE employment to population ratio - using PT 20 hrs - Rest of Australia"

* Creating the before and after estimates
gen before_wa=l3.sa_fte_wa
gen after_wa=f3.sa_fte_wa
gen diff_wa=f3.sa_fte_wa-l3.sa_fte_wa
gen before_ra=l3.sa_fte_ra
gen after_ra=f3.sa_fte_ra
gen diff_ra=f3.sa_fte_ra-l3.sa_fte_ra 

* Creating the difference-in-difference estimate
gen dd=(f3.sa_fte_wa-l3.sa_fte_wa)-(f3.sa_fte_ra-l3.sa_fte_ra)
for any 15_24 25_34 35_44 45_54 15_24m 25_34m 35_44m 45_54m 15_24f 25_34f 35_44f 45_54f m f 20h: gen ddX=(f3.sa_fte_waX-l3.sa_fte_waX)-(f3.sa_fte_raX-l3.sa_fte_raX)
gen employmenteffect=dd/mw
gen elasticity=employmenteffect/((before_wa+after_wa)/2)

* Calculating the standard errors, using data from the ABS tables
gen fte_employ_wa=(ft_wa+15/40*pt_wa)
gen fte_employ_ra=((ft_nsw+ft_vic+ft_q+ft_sa+ft_tas+ft_nt+ft_act)+15/40*(pt_nsw+pt_vic+pt_q+pt_sa+pt_tas+pt_nt+pt_act))
gen pop_ra=pop_nsw+pop_vic+pop_q+pop_sa+pop_tas+pop_nt+pop_act

* In 1994-2002, Western Australian FTE employment ranges from 656,000 to 793,000, while Western Australian civilian population ranges from 1303,000 to 1,529,000. 
* Using both the pre-Sept 1997 and the post-Sept 1997 tables, the RSE for employment is 0.009, and the RSE for population is 0.005
* Using the formula for RSE of a proportion, RSE=(.009^2-.005^2)^0.5=.007
* gen temp_fte_wa=(ft_wa+15/40*pt_wa)
* sum temp_fte_wa pop_wa if year>=1994

* In 1994-2002, Rest of Australia FTE employment ranges from 5,923,000 to 6,937,000, while Rest of Australia civilian population ranges from 12,556,000 to 14,022,000
* Using either set of tables, the RSE for employment is 0.006, while the RSE for population is 0.004
* Using the formula for RSE of a proportion, RSE=(.005^2-.004^2)^0.5=.003
*gen temp_fte_ra=((ft_nsw+ft_vic+ft_q+ft_sa+ft_tas+ft_nt+ft_act)+15/40*(pt_nsw+pt_vic+pt_q+pt_sa+pt_tas+pt_nt+pt_act))
*gen temp_pop_ra=(pop_nsw+pop_vic+pop_q+pop_sa+pop_tas+pop_nt+pop_act)
*sum temp_fte_ra temp_pop_ra if year>=1994

for any before after: gen X_wa_se=.007*X_wa 
for any before after: gen X_ra_se=.003*X_ra 
gen diff_wa_se=(before_wa_se^2+after_wa_se^2)^0.5
gen diff_ra_se=(before_ra_se^2+after_ra_se^2)^0.5
gen dd_se=(diff_wa_se^2+diff_ra_se^2)^0.5
gen employmenteffect_se=dd_se/mw
gen elasticity_se=employmenteffect_se/((before_wa+after_wa)/2)
gen stars=0
la var stars "Number of asterisks, denoting the P-value of the DD estimate"
for num 1.645 1.960 2.576 \ num 1/3: replace stars=Y if abs(dd/dd_se)>=X

**********************************************
* Results
**********************************************

* Basic DD tables (note that the variable "dot" is merely a placeholder, so that the table lines up nicely)
set more on
gen dot=.
for any 94 95 96 98 00 01: list before_wa before_ra dot before_wa_se before_ra_se dot after_wa after_ra dot after_wa_se after_ra_se dot diff_wa diff_ra dd diff_wa_se diff_ra_se dd_se dot dot employmenteffect dot dot employmenteffect_se dot dot elasticity dot dot elasticity_se stars if mw_X==1, display

* Combining the 6 estimates
reg dd mw, robust
outreg using sensitivity1.doc, coefastr se 3aster replace

* To calculate elasticity
egen temp=mean(sa_fte_wa) if year>=1994 & year<=2001
gen elasticity_combined=_b[mw]/temp
gen elasticity_combined_se=_se[mw]/temp
sum elasticity_combined elasticity_combined_se
drop elasticity_combined*

* Sensititivity test - excluding years one-by-one
for any 94 95 96 98 00 01: reg dd mw if mw_X==0, robust \ outreg using sensitivity1.doc, coefastr se 3aster append 

* To calculate elasticities
for any 94 95 96 98 00 01: reg dd mw if mw_X==0, robust \ gen elasticity_combined=_b[mw]/temp \ gen elasticity_combined_se=_se[mw]/temp \ sum elasticity_combined* \ drop elasticity_combined*
drop temp

* Testing by age and sex subgroups
reg dd15_24 mw, robust
outreg using sensitivity2.doc, coefastr se 3aster replace
for any 25_34 35_44 45_54 15_24m 25_34m 35_44m 45_54m 15_24f 25_34f 35_44f 45_54f: reg ddX mw, robust \ outreg using sensitivity2.doc, coefastr se 3aster append

* To calculate elasticities
for any 15_24 25_34 35_44 45_54 15_24m 25_34m 35_44m 45_54m 15_24f 25_34f 35_44f 45_54f: reg ddX mw, robust \ egen temp=mean(sa_fte_waX) if year>=1994 & year<=2001 \ gen elasticity_combined=_b[mw]/temp \ gen elasticity_combined_se=_se[mw]/temp \ sum elasticity_combined* \ drop elasticity_combined* temp

**********************************************
* Additional robustness checks. These aren't shown in the paper, 
* but may be useful in persuading the skeptics.
**********************************************

* Testing using PT=20hrs (instead of PT=15hrs)
reg dd20h mw, robust
outreg using sensitivity3.doc, coefastr se 3aster replace

* Sensitivity test. This uses every possible before and after period - eg. "22" is 2 months before, and 2 months after.
for X in num 1/4: for Y in num 1/4: gen diffXY=(fY.sa_fte_wa-lX.sa_fte_wa)-(fY.sa_fte_ra-lX.sa_fte_ra) 
reg diff11 mw, robust
outreg using sensitivity4.doc, coefastr se 3aster nocons nor2 nonobs nonotes replace
for num 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44: reg diffX mw, robust \ outreg using sensitivity4.doc, coefastr se 3aster nocons nor2 nonobs nonotes append

**********************************************
* Saving a simplified version of the dataset
**********************************************
keep sa_fte* before* after* diff* dd* mw*
drop diff1* diff2* diff3* diff4* 
save minimum_wage_data_web2.dta, replace

